export const getServerTime = () => {
  return new Promise((resolve, reject) => {
    const xhr = new XMLHttpRequest()
    xhr.open('HEAD', location.href, true)
    xhr.onreadystatechange = function () {
      if (xhr.readyState === 4 && xhr.status === 200) {
        resolve(Date.parse(xhr.getResponseHeader('Date')))
      }
    }
    xhr.send(null)
  })
}
